package com.gary.callable;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author peng_rui
 * @date 2022/3/16
 */
public class Demo {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> task = new FutureTask<>(() -> {
            System.out.println(Thread.currentThread().getName() + " i am callable");
            return 1024;
        });

        new Thread(task, "AA").start();

        while (!task.isDone()) {
            System.out.println("wait");
        }

        System.out.println(task.get());
    }
}
